package interface_graphique;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

public class Can extends JPanel{
	  public BufferedImage imgPoisson;
	  public BufferedImage imgFruit;
	  public BufferedImage imgLait;
	  public BufferedImage imgVin;
	  public BufferedImage imgJuis;
	  public BufferedImage imgPoulet;
	  public BufferedImage imgViande;
	  public BufferedImage imgLegume;
	  public int comptAff =0;
	  public static Frigo f;
	  
	  
	  public Can(Frigo frigo) {
		  this.f=frigo;
		  try {
		    	imgFruit =	ImageIO.read(new File("fruit.png"));
		    	imgLait =	ImageIO.read(new File("lait.png"));
		    	imgVin =	ImageIO.read(new File("vin.png"));
		    	imgJuis =	ImageIO.read(new File("juisOrange.png"));
		    	imgPoulet =	ImageIO.read(new File("poulet.png"));
		    	imgViande =	ImageIO.read(new File("viande.png"));
		    	imgLegume =	ImageIO.read(new File("legume.png"));
				imgPoisson = ImageIO.read(new File("poisson.png"));
				  
			} catch (IOException e) {
				e.printStackTrace();
			}
		  
  }
	
	  
	  public void paintComponent(Graphics g) {
	    int width = getWidth();
	    int height = getHeight();
	    //g.setColor(Color.black);
	    int i =1;
	    int j=1;
	   	
	    int x = 100+comptAff*100;
	    for (E_Type mapKey : f.inventaire.keySet()) {
			if (f.inventaire.get(mapKey).isEmpty())
				continue;
		 	E_Type u = E_Type.Fish;
			 		
				 if(mapKey.equals(u)){
					 g.drawImage(imgFruit, x, 70, null);
					 comptAff++;
				 }
				 else if(mapKey.equals(E_Type.Drink)){
					 g.drawImage(imgJuis, x,70,null);
					 comptAff++;
				 }
				 else if(mapKey.equals(E_Type.Dairy)){
					 g.drawImage(imgLait, x,70,null);
					 comptAff++;
				 }
				 else if(mapKey.equals(E_Type.Vegetable)){
					 g.drawImage(imgLegume, x,70,null);
					 comptAff++;
				 }
				 else if(mapKey.equals(E_Type.Meat)){
					 g.drawImage(imgViande, x,70,null);
					 comptAff++;
				 }
				 

		}
	   
	    g.drawImage(imgViande, 100,70,null);
	   
	   
	  
	   
	  }
	  
	  
	  
	
	

}
